import java.io.IOException;
import java.util.Scanner;

public class temp
{
	 public static Scanner scan = new Scanner(System.in);

     public static void main(String[] args)
     {
  	    int done = 1;
  	    
  		while(done == 1)
  		{
  			
  			// ask user for a graph file
  			System.out.println("Do you wanna run the program!? ");
	  		System.out.print(" press 1 to continue, 2 to quit -> ");
	  		int option = scan.nextInt();

	  		// if user want to play 
  		  	if(option == 1){
  		  		
  				// ask user to enter input file
  		  		AdjacencyList list = new AdjacencyList();
  				try {
  					list.enterInput();
  				} catch (IOException e) {
  					// TODO Auto-generated catch block
  					e.printStackTrace();
  				}

  				// print out the adjacent list
  		        System.out.println("Your AdjacencyList is showing as below");
  		        System.out.println(list);
  		  		

 		  		 System.out.print("Wanna do it again?" +
 	  		  		 		" Press 1 to continue, 2 to quit -> ");

 		  		 done = askInput();
 	                 if(done != 1)
 	      		  		System.out.println("Byebye!");
  			  }

  		  	else
  		  	{
  		  		System.out.println("Byebye!");
  		  		return;   // exit out the program
  		  	}
  		}

    }
     
     
		public static int askInput()
		{
	  		Scanner scan = new Scanner(System.in);
	  		String option = scan.nextLine();
	  		return Integer.parseInt(option);
		}
		
		
		public static void ask4Algorithm(AdjacencyList list)
		{

	        // ask user to pick a algorithms
	        System.out.println("1. for BFS");
	        System.out.println("2. for DFS");
	        System.out.println("3. for Dijkastra");
	        System.out.println("4. for Prim");

  			System.out.print("Please enter coorsponding algorithm's number"
  					+"\nwhich you want to run. i.e. 1 for BFS -> ");
  			
  			int alg = scan.nextInt();
	        
			/**
			 * Algorithm Generators
			 */
  			DataStructure<Record> ds;
  			String algorithm = "";
		        if(alg == 1)
		        {
		        	// BFS
		        	ds = new MyQ<Record>();
		        	algorithm = " BFS ";
		        }
		        else if (alg == 2)
		        {
		        	// DFS
		        	ds = new MyStack<Record>();
		        	algorithm = " DFS ";
		        }
	        	else if (alg == 3)
	        	{
	        		// Dijkstra
	        		ds= new MyPQ<Record>(new DijkstraComparator());
	        		algorithm = " Dijkstra ";
	        	}
        		else if (alg == 4)
        		{  
        			// Prim
        			ds= new MyPQ<Record>(new PrimComparator());
        			algorithm = " Prim ";
        		}
        		else
        		{
        			System.out.println("Invalid Option! I will assume" +
        					" you wanna do BFS. ");
			  		ds = new MyQ<Record>();
        		}
		    
		        System.out.print("Please pick a valid vertex" +
		        		"\n otherwise, I will assume its A->");
		        
		        String start = "";
		        if(scan.hasNext())
		        	start = scan.next().toUpperCase();
		        
		        // if not found, pick A
		        if(list.getSpecificVertex(start) != null)
		        	start = "A";
		        
		        System.out.println("What is Start? " +start);
		        
		        GraphTraverser graph = new GraphTraverser(ds,list,start);
			
		        
				System.out.println(algorithm + "result is showing below"); 
				graph.printPaths();
				graph.printEdge();
		}

}

